**************************
***	RUN USING STATA 16 ***
**************************
	
* Purpose: graphs the trend in difficulty-adjusted performance
* Last updated: 20 Apr 2023

*-----------------------------------------------------------------------

//trends of educational improvement over time
	use "$input\waec_pass.dta", clear
	keep yr mat_pass mat_a_c_perc
	ren mat_pass waec_pass
	ren mat_a_c_perc waec_credit
	keep if yr > 2010
	tempfile waec
	save `waec'
	
	use "$output\mat_pass_estimates.dta", clear
	
	ren c_ us_credit
	gen us_pass = us_credit + p_
	keep yr us_pass us_credit
	
	merge 1:1 yr using `waec'
	drop _merge
	drop if yr==2017
	
	//gen trend, pooled benchmark (pooled values are simply average pass and credit pass rates for the 2011-19 period)
	gen trend_p = 72 + waec_pass - us_pass
	gen trend_c = 41 + waec_credit - us_credit
	
	tw ///
	(line trend_p yr, lc(black)) ///
	(line trend_c yr, lc(black) lp(dash)) ///
	, xlabel(2011(1)2019, labsize(10pt)) ylabel(0(10)100, labsize(10pt)) ///
	legend(lab(1 "Pass") lab(2 "Credit or better") size(10pt) pos(6) col(2)) ///
	ytitle("% Reaching Pass and Credit Levels", size(10pt)) xtitle("Year", size(10pt)) ///
	xsize(4.5) ysize(3)
	graph export "$graph\3a.png", replace
	graph export "$graph\3a.eps", replace

*----------------------variance estimates

	su waec_pass
	local w = r(Var)
	su trend_p
	local u = r(Var)
	disp 1-(`u'/`w')
	
	su waec_credit
	local w = r(Var)
	su trend_c
	local u = r(Var)
	disp 1-(`u'/`w')

	



